// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class ShaderCtrl extends cc.Component {

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}
    time = 0;
    @property(cc.Material)
    material: cc.Material = null;
    start () {
        this.material = this.node.getComponent(cc.Sprite).sharedMaterials[0];
    }

    update (dt) {
        this.time += dt;
        // 更新材质的时间参数来控制滚动
        this.material.setProperty('time', this.time);
    }
}
